package fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class JsonStringToJsonObj {
    public static void main(String[] args) {
        //2-json字符串转json对象
        String jsonString = "{\"action\":\"add\",\"id\":\"1\",\"ordinal\":8,\"organUnitFullName\":\"testJSON\",\"parent\":\"0\",\"suborderNo\":\"58961\"}";

        JSONObject jsonObject = JSON.parseObject(jsonString);
        String action = jsonObject.getString("action");
        String id = jsonObject.getString("id");
        System.out.println("action =" + action);//add
        System.out.println("id =" + id);//1
        System.out.println("jsonObject =" + jsonObject);
        //action =add
        //id =1
        //jsonObject ={"parent":"0","organUnitFullName":"testJSON","action":"add","id":"1","suborderNo":"58961","ordinal":8}

    }
}
